﻿package UIComponents// ActionScript file
{
	import flash.display.Sprite;
	import flash.text.TextField;

	public class FrameNumTxt extends Sprite
	{
		private var _num:int;
		private var _oldColor:uint;
		public function FrameNumTxt():void
		{
			_oldColor	=	(this.getChildByName("txt_num") as TextField).textColor;	
			(this.getChildByName("xred") as TextField).visible		=	false;
		}
		
		public function reset():void
		{
			(this.getChildByName("txt_num") as TextField).text="";
		}

		/*getter & setter*/
		public function get num():int
		{
			return _num;
		}
	
		public function set num(value:int):void
		{
			_num = value;
			(this.getChildByName("txt_num") as TextField).text=String(value);
//			(this.getChildByName("txt_num") as TextField).textColor		=	_num<1?0xff0000:this._oldColor;
			setXColor();
		}
		
		public function setXColor():void
		{
			(this.getChildByName("txt_num") as TextField).textColor		=	_num<1?0xff0000:this._oldColor;
			
			(this.getChildByName("xred") as TextField).visible		=	false;
			(this.getChildByName("xgreen") as TextField).visible	=	false;
			if(_num<1)
				(this.getChildByName("xred") as TextField).visible		=	true;
			else
				(this.getChildByName("xgreen") as TextField).visible		=	true;
				
		}

	}
}